<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: relative;
            width: 500px;
            height: 500px;
            background-color: rgb(0, 81, 128);
        }
        p {
            position: absolute;
            top:50%;
            left: 50%;
            width: 200px;
            height: 200px;
            background-color: yellow;
            /* 1.自己想法transform: translate(150px,150px); */
            /* margin-top: -100px;
            margin-left: -100px;老版本写法 */
            transform: translate(-50%,-50%);
        }

    </style>
</head>
<body>
    <div>
        <p></p>
    </div> 
</body>
</html>